<div class="row">
<div class="col-md-3 blog-img blog-tag-data">
   <a href="<?php echo Yii::app()->createUrl('/Events/default/view', array('category'=>$data->category->url, 'url'=>$data->url)); ?>" class="clearfix" title="<?php echo $data->title; ?>">
                <img src="<?php echo IMAGES_URL . 'Events/150_85/' . $data->image; ?>" alt="<?php echo $data->title; ?>" width="150" />
            </a>
   <ul class="list-inline">
      <li><i class="icon-calendar"></i>
        <span class="event-left-date"><?php echo date('l', strtotime($data->startdate)); ?></span>   </li>
      <li><span class="event-left-day pull-right" style="margin-bottom:-5px"><?php echo date('d-m-Y', strtotime($data->startdate)); ?></span></li>
   </ul>
   <ul class="list-inline blog-tags">
      <li>
         <i class="icon-tags"></i>  
        <?php echo CHtml::link($data->category->title, array('/Events/categories/view', 'url'=>$data->category->url), array('title'=>$data->category->title)).' | '; ?>
        <?php if ($data->ticket === 'F') {
            echo CHtml::link('Miễn phí', array('/Events/categories/freeEvent'), array('title'=>'Sự kiện miễn phí', 'class'=>'event-ticket'));
        }
        elseif ($data->ticket === 'G') {
            echo CHtml::link('Ưu đãi', array('/Events/categories/giftEvent'), array('title'=>'Sự kiện ưu đãi, quà tặng', 'class'=>'event-ticket'));
        }
        else {
            echo CHtml::link('Có phí', array('/Events/categories/paidEvent'), array('title'=>'Sự kiện có phí', 'class'=>'event-ticket'));
        } ?>
      </li>
   </ul>
</div>
<div class="col-md-9 blog-article" style="margin-top: -20px;">
   <h3><?php echo CHtml::link($data->title, array('/Events/default/view', 'category'=>$data->category->url, 'url'=>$data->url), array('title'=>$data->title)); ?></h3>
   <span class="glyphicon glyphicon-map-marker"></span> 
   <?php if (!empty($data->locations)) {
                foreach ($data->locations as $location) {
                    // Kiểm tra xem có bản ghi địa điểm hay không
                    if ($location->place_id == 0) {
                        // Lấy thông tin từ bản ghi EventLocations
                        if (!empty($location->title)) { echo $location->title; };
                        if (!empty($location->location)) { echo ', ' . $location->location; };
                        if (!empty($location->address)) { echo ', ' . $location->address; };
                        if (!empty($location->ward)) { echo ', ' . $location->ward; };
                        if (!empty($location->district)) { echo ', ' . $location->district; };
                        if (!empty($location->city)) { echo ', ' . $location->city; };
                    }
                    elseif (!empty($location->place)) {
                        // Lấy thông tin từ bản ghi Places
                        if (!empty($location->place->title)) { echo $location->title; };
                        if (!empty($location->place->location->address)) { echo ', ' . $location->place->location->address; };
                        if (!empty($location->place->location->ward)) { echo ', ' . $location->place->location->ward; };
                        if (!empty($location->place->location->district)) { echo ', ' . $location->place->location->district; };
                        if (!empty($location->place->location->city)) { echo ', ' . $location->place->location->city; };
                    }
                    else {
                        echo 'Xem chi tiết';
                    }
                }
            }
            else {
                echo 'Xem chi tiết';
            } ?><br>
                <span class="glyphicon glyphicon-time"></span> 
                <?php echo date('H:i - l, \n\g\à\y d-m-Y', strtotime($data->startdate)); ?>
            <br>
            <?php if ($data->ticket === 'P'): ?>
            <span class="event-price">
                <span class="glyphicon glyphicon-usd"></span>
                <?php if (isset($data->price)) {
                    echo 'Giá từ ' . number_format($data->price->price, 0, '.', ',') . ' VNĐ';
                }
                else {
                    echo 'Liên hệ';
                } ?>
            </span>
            <span class="event-divider"></span>
            <?php endif; ?>
            <br>
            <span class="glyphicon glyphicon-eye-open"></span> <?php echo number_format($data->numviews, 0, '.', ','); ?> lượt xem
            <br>
   <a style="float:right" target="_blank" class="btn blue" href="<?php echo Yii::app()->createUrl('/Events/default/view', array('id'=>$data->id)); ?>">
   Xem chi tiết
   <i class="m-icon-swapright m-icon-white"></i>
   </a>
</div>
</div>
<hr>